import React from 'react'
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom'
import Login from '../views/Login'
import NewsSandBox from '../views/NewsSandBox'
export default function index() {
  return (
    <BrowserRouter>
      <Switch>
        {/* <Route exact path="/" component={NewsSandBox}></Route> */}
        <Route path="/login" component={Login}></Route>
        <Route
          path="/"
          render={() =>
            localStorage.getItem('token') ? (
              <NewsSandBox></NewsSandBox>
            ) : (
              <Redirect to="/login"></Redirect>
            )
          }
        ></Route>
      </Switch>
    </BrowserRouter>
  )
}
